if (CMAKE_BUILD_TYPE MATCHES "Debug")
  set(LTO_FLAG FALSE)
else()
  set(LTO_FLAG TRUE)
endif()

option(USERVER_LTO "Use link time optimizations" ${LTO_FLAG})

if(NOT LTO_FLAG AND NOT USERVER_LTO)
  message(STATUS "LTO: disabled (local build)")
elseif(NOT USERVER_LTO)
  message(STATUS "LTO: disabled (user request)")
else()
  message(STATUS "LTO: on")
  include("${USERVER_CMAKE_DIR}/RequireLTO.cmake")
endif()
